﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using King.Engine.Content;
using Microsoft.Xna.Framework;
using King.Engine.Core;
using BreacherCreature.GameObjects.Tiles;

namespace BreacherCreature
{
    
    public class MainLevelScheme : LevelScheme<GameActivity>
    {

        private static Dictionary<string, BuildLevelElement> _builders = new Dictionary<string, BuildLevelElement>()
        {
            {"CreatureAndEggSpawn", BuildCreatureAndEggSpawn},
            {"CreatureSpawn", BuildCreatureSpawn},
            {"Size", BuildWorld}
        };

        public MainLevelScheme()
            : base(_builders)
        {

        }

        private static void BuildCreatureSpawn(GameActivity activity, Dictionary<string, string> attributes)
        {
            int x = int.Parse(attributes["x"]);
            int y = int.Parse(attributes["y"]);
            activity.CreatureSpawn = new Point(x, y);
        }

        private static void BuildCreatureAndEggSpawn(GameActivity activity, Dictionary<string, string> attributes)
        {
            int x = int.Parse(attributes["x"]);
            int y = int.Parse(attributes["y"]);
            activity.CreatureSpawn = new Point(x, y);
            activity.EggPoint = new Point(x - 23, y);
        }

        private static void BuildWorld(GameActivity activity, Dictionary<string, string> attributes)
        {
            int x = int.Parse(attributes["x"]);
            int y = int.Parse(attributes["y"]);
            Screen.WorldSize = new Point(x, y);

            Floor floor = new Floor("FloorTileGrateNoHoles", x / Floor.SIZE + 1, y / Floor.SIZE + 1);
            activity.AddGameObject(floor);
        }

    }
     


}
